Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

buffer-from

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

buffer-from

A [ponyfill](https://ponyfill.com) for `Buffer.from`, uses native implementation if available.

  • 1.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is buffer-from?

The buffer-from npm package is a polyfill for the `Buffer.from` method that was added in Node.js v5.10.0. It allows users to create `Buffer` objects from various types of data such as strings, arrays, or other buffers. This package is particularly useful for environments that do not support the newer `Buffer.from` API.

What are buffer-from's main functionalities?

Creating a buffer from a string

This feature allows you to create a buffer from a string. The second argument specifies the string encoding.

const bufferFrom = require('buffer-from');
const buffer = bufferFrom('hello world', 'utf8');

Creating a buffer from an array

This feature allows you to create a buffer from an array of bytes.

const bufferFrom = require('buffer-from');
const buffer = bufferFrom([0x68, 0x65, 0x6c, 0x6c, 0x6f]);

Creating a buffer from another buffer

This feature allows you to create a new buffer from an existing buffer. The new buffer will be a copy of the original.

const bufferFrom = require('buffer-from');
const buffer1 = Buffer.alloc(10).fill('a');
const buffer2 = bufferFrom(buffer1);

Other packages similar to buffer-from

Keywords

FAQs

Package last updated on 29 Jul 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc